package com.clstu.outputstream_;

import java.io.Serializable;

public class Dog implements Serializable {//实现Serializable接口才能被存入文件（序列化）
    private String name = null;
    private int age = 0;

    private static String nation;//由 static 和 transient 修饰的成员不会被序列化(不被存入文件)
    private transient String color;

    private static final long serialVersionUID = 3L;//提高兼容性，避免小改动之后就不认这个类了

    private Master master = new Master();//新建成员，这个对象成员的类也必须要实现Serializable接口才能序列化

    public Dog(String name, int age,String nation,String color) {
        this.name = name;
        this.age = age;
        this.nation = nation;
        this.color = color;
    }

    public static String getNation() {
        return nation;
    }

    public static void setNation(String nation) {
        Dog.nation = nation;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return  "name='" + name + '\'' +
                ", age=" + age +
                ", color='" + color+
                ", nation='" + nation;
    }
}